#ifndef _PARTHUS_LMP_SECURITY_ENGINE_
#define _PARTHUS_LMP_SECURITY_ENGINE_

/******************************************************************************
 * MODULE NAME:   lmp_security_engine.h
 * PROJECT CODE:  BlueStream
 * DESCRIPTION:   Header File for the LMP Security Engine
 * MAINTAINER:    Daire McNamara
 * CREATION DATE: 24 December 2000
 *
 * SOURCE CONTROL: $Id: lmp_sec_engine.h,v 1.7 2008/11/08 07:30:04 tianwq Exp $
 *
 * LICENSE:
 *   This source code is copyright (c) 2000-2004 Ceva Inc.
 *   All rights reserved.
 *
 ******************************************************************************/

#include "sys_types.h"
#include "lmp_types.h"
#include "lmp_sec_types.h"

#define NO_ROUNDS 8
#define MAX_DEGREE_KC 127
#define BIT31 0x80000000UL
#define MAX_KEY_SIZE 16
#define MAX_KEY_REG_SIZE 4

typedef enum {AR_NORMAL, AR_MOD} saferplustag;

/* Used for Reduction of Encryption Key (Kc) */
typedef struct
{
    u_int16 value;
    u_int8 degree;
}polynomial;

void LM_SecEng_Authenticate_E1(u_int8* p_randinput, t_link_key key,
        const t_bd_addr* p_bd_addr, t_sres sres, t_aco aco);
void LM_SecEng_Generate_Key_E21(t_link_key randinput,
        const t_bd_addr* p_bd_addr, t_link_key output_key);
void LM_SecEng_Generate_Key_E22(const t_rand randinput, t_pin_code PIN,
        u_int8 lengthPIN, const t_bd_addr* p_bd_addr, t_link_key outputkey);
void LM_SecEng_Generate_Key_E3(t_rand encr_rand, t_cof cof,
        t_link_key current_link_key, t_rand encr_key);
void LM_SecEng_Generate_Kc_Prime(u_int8 * kc, u_int8 kc_prime_len,
        u_int8 *kc_prime);

#if (PRH_BS_CFG_SYS_LMP_SECURE_SIMPLE_PAIRING_SUPPORTED == 1)
void LM_SecEng_Generate_Local_Key(void); /* the key will store in g_LM_config_info */
void LM_SecEng_Wait_Local_Key(void); /* wait the public key */
void LM_SecEng_Generate_DHKey(t_DH_key *peer_public_key);
void LM_SecEng_Get_DHKey(t_DH_key dh_key);
 /* f1 */
void LM_SecEng_Generate_Commitment(t_DH_key local_public_key, t_DH_key peer_public_key,
                                            t_rand rand, u_int8 passkey, t_hash output);
/* g */
void LM_SecEng_Generate_Number(t_DH_key local_public_key, t_DH_key peer_public_key,
                                            t_rand local_rand, t_rand peer_rand, u_int32 *number);
/* f2 */
void LM_SecEng_Generate_Link_Key(t_DH_key dh_key, t_rand master_rand, t_rand slave_rand,
                                            const t_byte_bd_addr p_master_bd_addr, const t_byte_bd_addr p_slave_bd_addr,
                                            t_link_key outputkey);
/* f3 */
void LM_SecEng_Generate_Check(t_DH_key dh_key, t_rand local_number, t_rand peer_number,
                                            t_rand rand, u_int32 ioCap, const t_byte_bd_addr p_bd_addr1,
                                            const t_byte_bd_addr p_bd_addr2, t_hash output);
#endif

#endif

